package com.longcai.service.impl.goods;

import com.longcai.entity.homegood.ClyjGoodsBrand;
import com.longcai.entity.homegood.ClyjGoodsBrandType;
import com.longcai.entity.homepage.GoodsClass;
import com.longcai.mapper.goods.ClyjGoodsBrandMapper;
import com.longcai.service.goods.ClyjGoodsBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商品品牌表 服务实现类
 * </p>
 *
 * @author LWK
 * @since 2019-03-22
 */
@Service
public class ClyjGoodsBrandServiceImpl extends ServiceImpl<ClyjGoodsBrandMapper, ClyjGoodsBrand> implements ClyjGoodsBrandService {
	
	@Autowired
	ClyjGoodsBrandMapper brandMapper;
	
	@Override
	public List<GoodsClass> listByBrandId(String brandId) {
		return brandMapper.listByBrandId(brandId);
	}

	@Override
	public void insertType(ClyjGoodsBrandType goodsClas2s) {
		List<String> typeIds = goodsClas2s.getTypeIds();
		if(typeIds==null || typeIds.size()==0) {
			return;
		}
		for (String s : typeIds) {
			Map map = new HashMap();
			map.put("id", UUID.randomUUID().toString());
			map.put("brandId", goodsClas2s.getBrandId());
			map.put("typeId", s);
			brandMapper.insertType(map);
		}
	}

	@Override
	public void deleteType(ClyjGoodsBrandType goodsClas2s) {
		brandMapper.deleteType(goodsClas2s.getBrandId());
	}

}
